<?php
if(isset($_GET['action']) && $_GET['action']=="travel-agent")
{
	$agent =  $_GET['agent'];
	$company =  $_GET['company'];
	
	$output = '
			<div class="clear"></div>
			<hr>
			<div class="clear"></div>
			<div class="thanks">
            	<img src="'.get_bloginfo('template_url').'/images/thanks_03.gif" alt="" />
                <p><strong>Info & Availability :</strong> Enjoy 3 nights in one of our beautiful decorated rooms or bungalows. Away from the hustle and bustle of the city, entertaining with our exclusive golf (playing to the beach), enjoying many free activities at our amusement park, and relaxing with foot spa package at our Song Lo spa...</p>

				<p><strong>Being the first hit to the sea driving range in Vietnam, what Diamond Bay Driving Range has to offer is unique to the industry and are excited to serve the golf community.</strong></p>
				<p style="text-align:center;">
					<img src="'.get_bloginfo('template_url').'/images/bgthanks_03.png" alt="" />
                	<a href="'.get_bloginfo("home").'"><img src="'.get_bloginfo('template_url').'/images/backhomes_07.png" alt="" /></a>
                </p>
             </div>
	';
	echo $output;
}

if(isset($_GET['action']) && $_GET['action']=="subscriber")
{
	include TEMPLATEPATH.'/mails/subscriber_template_mail.php';
	// xu ly truong hop dang ky nhan mail
	include TEMPLATEPATH.'/incs/subscriber/process.php';
	$email = $_GET['value'];
	$email = str_ireplace("00000", "@", $email);	
	if(db_check_exists_text('subscriber','email', $email))
	{
		echo 'Email is exists,are you want choose other email?';	
	}
	else 
	{
		if(db_subscriber_send_email($email))
		{
			db_subscriber_insert($email);
			echo 'Register email success full!';
		}
		else 
		{
			echo "Register email Failed,Send mail failed.";
		}
	}
}
## xu ly trang index
else if(isset($_GET['action']) && $_GET['page']=="index")
{
	if($_GET['action']=="tours")
	{
		$html = null;		
	    $num_post	= 6;
	    $post_type	= 'tour';
	    $taxonomy	= 'tourism';
	    $field		= 'slug';	    
	    $metakey	= $wpdb->prefix.'display';
	    $metavalue  = 'display';
	    $term = $_GET['value'];
	    if($term=="others-tourism")
	    {
	    	$field		= 'id';
	    	$term = array();
	    	$args = array('title_li'  => '','orderby' => 'id','taxonomy' => $taxonomy,'hide_empty' => 0,'hierarchical'  => true,'depth'  => 1);
	    	$cates = get_categories($args);
	    	if($cates)
	    	{
		    	foreach ($cates as $value) 
		    	{
		    		if(check_category($value->name))
		    			$term[] = $value->term_id;		    		
		    	}
	    	}
	    	$hotels = db_query_posts_in_terms_child_nopage_exclude($num_post, $post_type, $taxonomy, $field, $term, $metakey, $metavalue);
	    }
	    else	    
	    	$hotels = db_query_posts_in_terms_child_nopage($num_post, $post_type, $taxonomy, $field, $term, $metakey, $metavalue);
	    query_posts($hotels); 
	    $html.='<ul>';                	    
	    require_once TEMPLATEPATH.'/views/tour/loop-tour.php';                         
	 	$html.='</ul>'; 
	 	  
	 	echo $html;                   
	}
	else if($_GET['action']=="hotels")
	{
		$html = null;		
	    $num_post	= 3;
	    $post_type	= 'post';
	    $taxonomy	= 'category';
	    $field		= 'slug';
	    //$term		= 'in-viet-nam';
	    $metakey	= $wpdb->prefix.'display';
	    $metavalue  = 'display';
	    $term = $_GET['value'];
	    if($term=="hotel-in-other")
	    {
	    	$field		= 'id';
	    	$term = array();
	    	$args = array('title_li'  => '','orderby' => 'id','taxonomy' => 'category','hide_empty' => 0,'hierarchical'  => true,'depth'  => 1);
	    	$cates = get_categories($args);
	    	if($cates)
	    	{
		    	foreach ($cates as $value) 
		    	{
		    		if(check_category($value->name))
		    			$term[] = $value->term_id;		    		
		    	}
	    	}
	    	$hotels = db_query_posts_in_terms_child_nopage_exclude($num_post, $post_type, $taxonomy, $field, $term, $metakey, $metavalue);
	    }
	    else 
	    	$hotels = db_query_posts_in_terms_child_nopage($num_post, $post_type, $taxonomy, $field, $term, $metakey, $metavalue);
	    
	    query_posts($hotels); 
	    $html.='<ul>';                	    
	    require_once TEMPLATEPATH.'/views/hotel/loop-hotel.php';                         
	 	$html.='</ul>';     
	 	echo $html;
	}
}
else if(isset($_GET['action']) && $_GET['page']=="tours")
{
	 	$html = null;		
	    $num_post	= 18;
	    $post_type	= 'tour';
	    $taxonomy	= 'category';
	    $field		= 'slug';
	    //$term		= 'in-viet-nam';
	    $metakey	= $wpdb->prefix.'display';
	    $metavalue  = 'display';
	    $term = $_GET['value'];
	    
	    if($term=="tourism-in-other")
	    {
	    	$field		= 'id';
	    	$term = array();
	    	$args = array('title_li'  => '','orderby' => 'id','taxonomy' => 'category','exclude'	=> array(1),'hide_empty' => 0,'hierarchical'  => true,'depth'  => 1);
	    	$cates = get_categories($args);
	    	if($cates)
	    	{
		    	foreach ($cates as $value) 
		    	{
		    		$term[] = $value->term_id;
		    		
		    	}
	    	}
	    	$hotels = db_query_posts_in_terms_child_nopage_exclude($num_post, $post_type, $taxonomy, $field, $term, $metakey, $metavalue);
	    }
	    else
	    	$hotels = db_query_posts_in_terms_child_nopage($num_post, $post_type, $taxonomy, $field, $term, $metakey, $metavalue);
	    query_posts($hotels); 
	    $html.='<ul>';                	    
	    require_once TEMPLATEPATH.'/views/tour/loop-tour.php';                         
	 	$html.='</ul>';     
	 	echo $html;              
}
?>